from django.conf import settings
from django import forms

YUI_PREFIX = getattr(settings, 'YUI_PREFIX',
        "http://yui.yahooapis.com/2.5.2/build/")
YUI_JS = {
    'button': 'button/button-min.js',
    'container': 'container/container-min.js',
    'json': 'json/json-min.js',
    'selector': 'selector/selector-beta-min.js',
    'uploader': 'uploader/uploader-experimental.js',
    'utilities': 'utilities/utilities.js',
}

YUI_CSS = {
    'button': 'assets/skins/sam/button.css',
    'container': 'container/assets/skins/sam/container.css',
    'fonts': 'fonts/fonts-min.css',
}

def get_yui(*components):
    return [ "%s%s" % (YUI_PREFIX, YUI_JS[c]) for c in components 
            if YUI_JS.get(c)]

def get_yui_css(*components):
    return [ "%s%s" % (YUI_PREFIX, YUI_CSS[c]) for c in components 
            if YUI_CSS.get(c) ]

def tinymce(custom_init=None):
    js = []
    for script in ['%stiny_mce/tiny_mce.js', '%sjs/curator/tinymce.js']:
        js.append(script % settings.ADMIN_MEDIA_PREFIX)
    if custom_init is None:
        js.append('%sjs/curator/tinymce_init.js' % settings.ADMIN_MEDIA_PREFIX)
    else:
        js.append(custom_init)
    return js
